<table bordercolor="#0d48e0" border="1" class="panel-table" style="width: 100%">
  <tbody>
    <tr align="center" class="aaa">
      <td style="color: rgb(0, 252, 255); font-size: 18px; padding: 5px 0px" style="width: 25%">
        最大值
      </td>
      <td style="color: rgb(0, 252, 255); font-size: 18px; padding: 5px 0px" style="width: 25%">
        最小值
      </td>
      <td style="color: rgb(0, 252, 255); font-size: 18px; padding: 5px 0px" style="width: 25%">
        实时
      </td>
      <td style="color: rgb(0, 252, 255); font-size: 18px; padding: 5px 0px" style="width: 25%">
        平均值
      </td>
    </tr>
    <tr align="center" class="aaa" style="font-size: 18px">
      <td style="width: 25%;height: 35px" id="monitor-max">{{ $max }}</td>
      <td style="width: 25%;height: 35px" id="monitor-min">{{ $min }}</td>
      <td style="width: 25%;height: 35px">
        <span id="monitor-now">{{ $now }}</span>
        <br> 
        <span style="font-size: 13px" id="monitor-time">{{ $time }}</span>
      </td>
      <td style="width: 25%;height: 35px" id="monitor-avg">{{ $avg }}</td>
    </tr>
  </tbody>
</table>

<script type="text/javascript">
    Dcat.ready(function () {
        setTimeout(getCabinetMonitorData{{ $cabinetId }}, 1000*{{ $autoRefresh }});
     
        function getCabinetMonitorData{{ $cabinetId }}() {
            if (window.parent.location.href.indexOf('cabinet-monitor') < 0) {
              return;
            }

            setTimeout(getCabinetMonitorData{{ $cabinetId }}, 1000*{{ $autoRefresh }});

            let url = "{{ URL::asset('admin/getCabinetMonitorData') }}";
            let data = {
                _token: '{{ csrf_token() }}',
                alias: '{{ $alias }}',
                time: {{ strtotime($time) }},
                cabinetId: {{ $cabinetId }}
            }
            $.ajax({
                type : "POST",
                url : url,
                data : data,
                success : function(result) {
                    console.log(result)
                    if (result.code == 1) {
                        $("#monitor-max").html(result.data.max);
                        $("#monitor-min").html(result.data.min);
                        $("#monitor-now").html(result.data.now);
                        $("#monitor-time").html(result.data.time);
                        $("#monitor-avg").html(result.data.avg);
                    } else {
                        console.log(result.msg)
                    }
                },
                //请求失败，包含具体的错误信息
                error : function(e){
                    layer.close(e);
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });
        }
    });
</script>